﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HexagonWeb.DAL;
using HexagonWeb.IBIL;
using HexagonWeb.Models;

namespace HexagonWeb.BIL
{
    public class SeatService : BaseService<Seat>, InterfaceSeatService
    {
        public SeatService() : base(RepositoryFactory.SeatRepository) { }

        public Seat Find(int AirlineID)
        {
            return CurrentRepository.Find(u => u.AirlineID == AirlineID);
        }

        public SeatViewModel FindSeat(int AirlineID, int level)
        {
            //SeatViewModel seatViewModel;
            //var _seat = this.Find(AirlineID);
            //if(_seat != null)
            //{
              
            //    //经济等级
            //    if (level == 0)
            //    {
            //        if(_seat.LowNum == 280)
            //            return null;
            //        seatViewModel = new SeatViewModel()
            //        {
            //            AirlineID = AirlineID,
            //            Level = 0,
            //            Row = (_seat.LowNum + 1) / 8 + 1,
            //            Column = (_seat.LowNum + 1) % 8,
            //        };
            //    }
            //    //商业等级
            //    if (level == 1)
            //    {
            //        if(_seat.MidNum == 42)
            //            return null;
            //        seatViewModel = new SeatViewModel()
            //        {
            //            AirlineID = AirlineID,
            //            Level = 1,
            //            Row = (_seat.LowNum + 1) / 6 + 1,
            //            Column = (_seat.LowNum + 1) % 6,
            //        };
            //    }
            //    //最高等级
            //    if (level == 2)
            //    {
            //        if(_seat.TopNum == 18)
            //            return null;
            //        seatViewModel = new SeatViewModel()
            //        {
            //            AirlineID = AirlineID,
            //            Level = 2,
            //            Row = (_seat.LowNum + 1) / 6 + 1,
            //            Column = (_seat.LowNum + 1) % 6,
            //        };
            //    }
            //    return seatViewModel;
            //}
            return null;
       }
    }
}